#!/bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test of GtkBuilder support.
# Checks that the extracted pot contains the right translatable
# content, comments and context.

cat <<\EOF > xg-gl-6-empty.glade
<?xml version="1.0"?>
<GTK-Interface/>
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} -o xg-gl-6.pot xg-gl-6-empty.glade 2>/dev/null
test $? = 0 || {
  echo "Skipping test: xgettext was built without Glade support"
  Exit 77
}

cat <<\EOF > xg-gl-6.ui
<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <!-- interface-requires gtk+ 3.0 -->
  <object class="GtkWindow" id="window">
    <property name="can_focus">False</property>
    <property name="title" translatable="yes" context="This is the context for this text" comments="This is a comment for empty window">This is an empty window</property>
    <child>
      <placeholder/>
    </child>
  </object>
</interface>
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} -o xg-gl-6.tmp xg-gl-6.ui || Exit 1
func_filter_POT_Creation_Date xg-gl-6.tmp xg-gl-6.pot

cat <<\EOF > xg-gl-6.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#. This is a comment for empty window
#: xg-gl-6.ui:6
msgctxt "This is the context for this text"
msgid "This is an empty window"
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-gl-6.ok xg-gl-6.pot
result=$?

test $result = 0 || {
  exit $result
}

# Check with --extract-all option.
${XGETTEXT} -a -o xg-gl-6.tmp xg-gl-6.ui || Exit 1
func_filter_POT_Creation_Date xg-gl-6.tmp xg-gl-6.pot

# Must be ignored.
${DIFF} xg-gl-6.ok xg-gl-6.pot
result=$?

exit $result
